/*
 * mock_network.hpp
 *
 *  Created on: 06.05.2011
 *      Author: inkooboo
 */

#ifndef _NET_MOCK_NETWORK_HPP_
# define _NET_MOCK_NETWORK_HPP_

# include <boost/noncopyable.hpp>
# include <boost/signals2.hpp>
# include <boost/thread/mutex.hpp>
# include <boost/shared_ptr.hpp>
# include <boost/asio/io_service.hpp>

# include <map>

class channel_t
{
public:
    void send(const char * data, size_t size);

    boost::signals2::signal<void(const char *, size_t)> on_data_;
private:

    void do_send();

    std::string data_;
};

class mock_network_t : private boost::noncopyable
{
    typedef std::map<std::string, boost::shared_ptr<channel_t> > channel_map_t;
public:
    static mock_network_t &instance();

    boost::shared_ptr<channel_t> &get_channel(const std::string &channel_name);

    boost::asio::io_service &get_svc();

private:
    mock_network_t() {};

    boost::mutex guard_;

    channel_map_t channel_map_;

    boost::asio::io_service svc_;
};

#endif /* _NET_MOCK_NETWORK_HPP_ */
